package com.cmcc.aregister.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cmcc.aregister.R;

public class TextAdapter extends BaseAdapter {
	private Context context;
	private LayoutInflater mInflater;
	private String[] array;
	private int color;
	public int select = -1;

	public TextAdapter(Context context, int array, int color) {
		this.context = context;
		this.mInflater = LayoutInflater.from(context);
		this.array = context.getResources().getStringArray(array);
		this.color = color;
	}

	public int getCount() {
		return array.length;
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(R.layout.a_gallery_text, null);
		TextView textview = (TextView) convertView.findViewById(R.id.textview);
		textview.setText(array[position]);
		textview.setTextColor(context.getResources().getColor(color));
		if (position == select) {
			//textview.setBackgroundResource(R.drawable.top_three_text_s);
		    textview.setTextColor(context.getResources().getColor(R.color.sky_blue));
		} else {
			//textview.setBackgroundResource(R.drawable.top_three_text_u);
		    textview.setTextColor(context.getResources().getColor(R.color.gray));
		}
		return convertView;
	}
}